$(document).ready(function(){
    $('#user-list-table').bootstrapTable({
        method: 'post',
        url: '/Home/Admin/getNormalUserReportList',
        dataType: "json",
        striped: true,	 //使表格带有条纹
        pagination: true,	//在表格底部显示分页工具栏
        cache: false,
        pageSize: 22,
        pageNumber: 1,
        pageList: [10, 20, 50, 100, 200, 500],
        //showToggle: false,   //名片格式
        //cardView: false,//设置为True时显示名片（card）布局
        //showColumns: true, //显示隐藏列
        //showRefresh: true,  //显示刷新按钮
        //singleSelect: true,//复选框只能选择一条记录
        search: true,//是否显示右上角的搜索框
        //clickToSelect: true,//点击行即可选中单选/复选框
        //sidePagination: "server",//表格分页的位置
        //queryParams: function(params){
        //    var querydata = {
        //        searchkey:search_para
        //    };
        //    console.log(querydata);
        //    return querydata;
        //}, //参数
        //queryParamsType: "limit", //参数格式,发送标准的RESTFul类型的参数请求
        toolbar: "#toolbar", //设置工具栏的Id或者class
        silent: true,  //刷新事件必须设置
        formatLoadingMessage: function () {
            return "...";
        },
        formatNoMatches: function () {  //没有匹配的结果
            return '无符合条件的记录';
        },
        onLoadError: function (data) {
            $('#reportTable').bootstrapTable('removeAll');
        },
        onClickRow: function (row) {

            $("#edit-uid").html(row.uid);
            $("#edit-username").val(row.username);
            $("#edit-useremail").val(row.email);
            $("#edit-user").modal('show');

            $("#edit-user-save").click(function(){
                var username;
                var useremail;
                ($("#edit-username").val() == row.username)?username='':username = $("#edit-username").val();
                ($("#edit-useremail").val() == row.email)?useremail='':useremail = $("#edit-useremail").val();
                $.ajax({
                    type:"POST",
                    url:"/Home/Orgnizer/updateUserInfo",
                    dataType:"json",
                    async : false,
                    data:{
                        uid:row.uid,
                        username:username,
                        useremail:useremail,
                        userpassword:$("#edit-userpassword").val()
                    },
                    success:function(data){
                        alert(data.msg);

                    },error: function (jqXHR) {
                        alert("failed"+jqXHR.status);
                    }
                });
            });

        },
        columns:[
            {
                field:'uid',
                title:'uid'
            },{
                field:'username',
                title:'用户名'
            },{
                field:'email',
                title:'邮箱'
            }]
    });
});

